package leetcode_core.leetcode_1;

import org.junit.Test;

public class Rob3 {
    public int rob(int[] nums) {
        int dp_i_1 = 0,dp_i_2=0,dp_i=0;
        for(int i= nums.length-1;i>=0;i--){
            dp_i = Math.max(dp_i_1,nums[i]+dp_i_2);
            dp_i_2 = dp_i_1;
            dp_i_1 = dp_i;
        }
        return dp_i;
    }
    @Test
    public void testCaseOne(){
        System.out.println(rob(new int[]{1, 2, 3,1}));
    }
    @Test
    public void testCaseTwo(){
        System.out.println(rob(new int[]{2,7,9,3,1}));
    }
}
